﻿using EF.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EF.Controllers
{
    public class HomeController : Controller
    {
        EShopV10 db = new EShopV10();

        public ActionResult Index()
        {
            ViewBag.Products = db.Products
                .OrderBy(p => Guid.NewGuid())
                .ToList()
                .Take(4);

            ViewBag.Categories = db.Categories
                .Where(c => c.Products.Count > 5)
                .OrderBy(c => Guid.NewGuid())
                .ToList()
                .Take(3);

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        

        public ActionResult CategoryMenu()
        {
            var model = db.Categories;
            return PartialView("_CategoryMenu", model);
        }
    }
}